# vPresent is an immersive presentation creation and display application.
# Copyright (C) 2007-2009 by Priority 5 Holdings, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

import os.path
from PyQt4 import QtCore

import gui.fileio.xml as od_xml
import gui.util
import gui.util.qthelpers


const = gui.util.const

def createPresentationFromSkeleton(builder, docDir):
   reader = od_xml.Reader(builder)

   base_doc_file      = os.path.join(docDir, 'content.xml')
   base_meta_file     = os.path.join(docDir, 'meta.xml')
   base_styles_file   = os.path.join(docDir, 'styles.xml')
   base_settings_file = os.path.join(docDir, 'settings.xml')

   doc_root      = gui.util.qthelpers.loadXMLDocument(base_doc_file,
                                                      QtCore.QIODevice.ReadOnly)
   meta_root     = gui.util.qthelpers.loadXMLDocument(base_meta_file,
                                                      QtCore.QIODevice.ReadOnly)
   styles_root   = gui.util.qthelpers.loadXMLDocument(base_styles_file,
                                                      QtCore.QIODevice.ReadOnly)
   settings_root = gui.util.qthelpers.loadXMLDocument(base_settings_file,
                                                      QtCore.QIODevice.ReadOnly)

   reader.construct(doc_root.documentElement(), meta_root.documentElement(),
                    styles_root.documentElement(),
                    settings_root.documentElement())

   return builder.getPresentation()
